package com.artron.mediaartron.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.artron.baselib.utils.UIUtils;

/**
 * Class description here
 *
 * @author doing
 * @version 1.0.0
 * @since 2017-12-06.
 */

public class SharePreferenceUtils {

    private static final String SHARE_NAME = "Share_Constant";
    private SharedPreferences preferences;
    private SharePreferenceUtils(){
        preferences = UIUtils.getContext().getSharedPreferences(SHARE_NAME, Context.MODE_APPEND);
    }
    private static SharePreferenceUtils instance = new SharePreferenceUtils();
    public static SharePreferenceUtils getInstance() {
        return instance;
    }

    public void putString(String key, String value) {
        preferences.edit().putString(key, value).apply();
    }

    public String getString(String key, String defaultValue) {
        return preferences.getString(key, defaultValue);
    }

    public void putInt(String key, int value) {
        preferences.edit().putInt(key, value).apply();
    }

    public int getInt(String key, int defaultValue) {
        return preferences.getInt(key, defaultValue);
    }

    public void putBoolean(String key, boolean value) {
        preferences.edit().putBoolean(key, value).apply();
    }

    public boolean getBoolean(String key, boolean defaultValue) {
        return preferences.getBoolean(key, defaultValue);
    }
}
